import { message } from 'antd';
import * as Api from './service';


export default {
  namespace: 'order',
  state: {
    merchantLst: [],
    merchantOrderLst: {},
    cooperationLst: [],
    busniessList: [],
  },
  reducers: {
    // updateMerchant(state, { payload: resData }) {
    //   return { ...state, merchantLst: resData };
    // },
    updateMerchantOrderLst(state, { payload: resData }) {
      return { ...state, merchantOrderLst: resData };
    },
    updateCooperationLst(state, { payload: resData }) {
      return { ...state, cooperationLst: resData };
    },
    updateBusniessLst(state, { payload: resData }) {
      return { ...state, busniessList: resData };
    },
    clear() {
      return {};
    },
  },
  effects: {
    // *getMerchantLst({ payload }, { call, put }) {
    //   const { data } = yield call(Api.getMerchantLst, payload);
    //   yield put({ type: 'updateMerchant', payload: data.data || [] });
    // },
    *getCooperationLst({ payload }, { call, put }) {
      const { data } = yield call(Api.getCooperationLst, payload);
      yield put({ type: 'updateCooperationLst', payload: data.data || [] });
    },
    *getMerchantOrderLst({ payload }, { call, put }) {
      const { data } = yield call(Api.getMerchantOrderLst, payload);
      yield put({ type: 'updateMerchantOrderLst', payload: data.data || [] });
    },
    *getBusniessLst({ payload }, { call, put }) {
      const { data } = yield call(Api.getBusniessLst, payload);
      if (data.rspCd == '00000') {
        yield put({ type: 'updateBusniessLst', payload: data.data });
      } else {
        message.error(data.rspInf || '查询失败');
      }
    },
  },
};
